package xyz.cerberu.cet.global.service;

import xyz.cerberu.cet.anime.dao.AnimeDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author β世界
 * Created on 17:53
 * @Description 全局服务
 */
@Service
public class CommonService {
    private final AnimeDao animeDao;

    @Autowired
    public CommonService(AnimeDao animeDao) {
        this.animeDao = animeDao;
    }

    /**
     * @author β世界 on 16:04 2020/4/26
     * @Description 获取历年的年份
     **/
    public String[] getFormerYears(){
        String[] years = animeDao.selectYear();
        for (int i = 0; i < years.length; i++) {
            // 截取
            years[i] = years[i].substring(0,years[i].indexOf("-"));
        }
        return years;
    }

}
